<? $mAUTH = $aid;

//$url = "http://www.tthfanfic.com/authors.php?no=".$mAUTH;
$url = "http://www.tthfanfic.com/AuthorStories-".$mAUTH."/";
echo $url."<br>";
	$fdat =  file ( $url );
while(list($key1,$val1)=each($fdat)){
	if(stristr($val1,"<div class='story")){
		$valA .="\n".$val1;
	}
}
$val1=$valA;
$valDat = explode("<div class='story",$val1);
while(list($key1,$val1)=each($valDat)){
	if(stristr($val1,"title titlecolors'>")){
		$collection=$collection+1;
		$trim1 = str_replace("title titlecolors'><a href='/Story-","",$val1);
		$t1 = stristr($trim1,"/");
		$dataA[$collection]['id'] = str_replace($t1,'',$trim1);
		$dataA[$collection]['title'] = trim(strip_tags(str_replace("'>",'',stristr($t1,"'>"))));
	}elseif(stristr($val1,"desc'>")){
		$dataA[$collection]['summary']=trim(strip_tags(str_replace("desc'>","",$val1)));
	}elseif(stristr($val1,"details'>")){
		//echo htmlspecialchars($val1)."<hr>";
		$vt1 = explode('/Author-',$val1);
		$vt2 = explode('</a>',$vt1[1]);
		$vt3 = explode("'>",$vt2[0]);
			$aidt =explode("/", $vt3[0]);
			$dataA[$collection]['author_id'] =$aidt[0];
			$dataA[$collection]['author'] = trim(str_replace('-:-','',strip_tags($vt3[1])));
		$vt3 = explode('Chapters&nbsp;[',$vt2[1]);
		$vt4 = explode("]",$vt3[1]);
		if($collection!=0){
			$dataA[$collection]['chapters'] = trim(str_replace("' onClick='return confirm(&quot;I am old enough to read this&quot;)","",str_replace("'>",'',$vt4[0])));
		}
		$vt1 = explode("Published&nbsp;[",$val1);
		$vt2 = explode("]",$vt1[1]);
			//echo $vt2[0]."<br>";
		if($collection!=0){
			$vt3 = explode("&nbsp;",$vt2[0]);
			$vt4 = $vt3[1]." ".$vt3[0]." 20".$vt3[2];
			$dataA[$collection]['published'] = date("Y-m-d", strtotime($vt4));				
		}
		$vt1 = explode("Updated&nbsp;[",$val1);
			$vt2 = explode("]",$vt1[1]);
			//echo $vt2[0]."<br>";
		if($collection!=0){
			$vt3 = explode("&nbsp;",$vt2[0]);
			$vt4 = $vt3[1]." ".$vt3[0]." 20".$vt3[2];
			$dataA[$collection]['updated'] = date("Y-m-d", strtotime($vt4));					
		}				
	}else{
		//echo htmlspecialchars($val1)."<hr>";
	}	
}

echo '<pre>';
var_dump($dataA);
exit();

	while(list($key,$val)=each($dataA)){
		if($mAUTH==$val['author_id']){ $mSTAT = '?'; }else{ $mSTAT = 'B'; }
		$sql = "INSERT INTO `fic_listing` ( `story_id` , `author_id` , `story_title` , `chapters` , `published` , `updated` , `status`,`summary`,`inserted` ) VALUES ('".$val['id']."', '".$val['author_id']."', '".str_replace("'","''",$val['title'])."', '".$val['chapters']."', '".$val['published']."', '".$val['updated']."', '".$mSTAT."','".str_replace("'","''",$val['summary'])."', NOW())";
		$cnt = $cnt + 1;
		$rs1 = $db->Execute($sql);
		if($rs1===false){ 
			$err = $db->ErrorMsg();
			if(stristr($err,'Duplicate entry')){
					$sqT = "chapters='".$val['chapters']."',updated='".$val['updated']."'";
						$sqT .= ", published='".$val['published']."'";						
						$sqT .= ", author_id='".$val['author_id']."'";						
						$sqT .= ", summary='".str_replace("'","''",$val['summary'])."'";	
						$sqT .= ", story_title='".str_replace("'","''",$val['title'])."'";	
					
						$sqlU = "UPDATE fic_listing SET ".$sqT." WHERE sitekey='T' and story_id='".$val['id']."'";
					//echo $sqlU."<hr>";
						$db->Execute($sqlU);
					
				//echo "<br>";
			}else{
				echo "<b>".$err."</b>";
			}
		}else{
			$cnt_n = $cnt_n + 1;
			//if new story try to insert author		
			$sql2 = "INSERT INTO `fic_authors` ( `author_id` , `author_name` )VALUES ('".$val['author_id']."', '".str_replace("'","''",$val['author'])."')";
			$rs2 = $db->Execute($sql2);
			//if($rs2===false){ echo $db->ErrorMsg()."<br>"; }
		}
	}

	$parSQL = "UPDATE fic_authors SET last_scan = NOW() WHERE sitekey='T' and author_id='".$mAUTH."'";
	//echo $parSQL."<hr>";
	$db->Execute($parSQL);
	
?><hr><pre><? 
		//var_dump($dataA); 
		?>
</pre>